package com.softhinker.ke24.unit3.model;

import java.io.Serializable;

public class Affordability implements Serializable {

	private static final long serialVersionUID = 5197468672204111497L;

	private double affordableMaximumLost = 0.0;
	/**
	 * -1 : No
	 * 0 : Maybe
	 * 1 : Yes
	 */
	private int continueToInvest = 0;
	
	public double getAffordableMaximumLost() {
		return affordableMaximumLost;
	}
	public void setAffordableMaximumLost(double affordableMaximumLost) {
		this.affordableMaximumLost = affordableMaximumLost;
	}
	public int getContinueToInvest() {
		return continueToInvest;
	}
	public void setContinueToInvest(int continueToInvest) {
		this.continueToInvest = continueToInvest;
	}
	
	public String toString(){
		return "Affordable maximum lost : " + this.getAffordableMaximumLost() * 100 + "%\n"
				+ "Continue to invest ? " + this.continueToInvest;
	}
	
	public int getValue(){
		int value = 0;
		if(this.getAffordableMaximumLost() > 0 && this.getAffordableMaximumLost() <= 0.1){
			switch(this.getContinueToInvest()){
			case 1 : value = 3;
					break;
			case 0 : value = 2;
					break;
			case -1 : value = 1;
					break;
			}
		}
		else if(this.getAffordableMaximumLost() > 0.1 && this.getAffordableMaximumLost() <= 0.3){
			switch(this.getContinueToInvest()){
			case 1 : value = 8;
					break;
			case 0 : value = 5;
					break;
			case -1 : value = 2;
					break;
			}
		}
		else if(this.getAffordableMaximumLost() > 0.3 && this.getAffordableMaximumLost() <= 0.6){
			switch(this.getContinueToInvest()){
			case 1 : value = 9;
					break;
			case 0 : value = 6;
					break;
			case -1 : value = 3;
					break;
			}
		}
		else if(this.getAffordableMaximumLost() > 0.6 && this.getAffordableMaximumLost() <= 1.0){
			switch(this.getContinueToInvest()){
			case 1 : value = 10;
					break;
			case 0 : value = 7;
					break;
			case -1 : value = 4;
					break;
			}
		}
		
		return value;
	}
}
